package edu.gatech.volt2.drdoommgt.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

import javax.swing.JTextField;
import javax.swing.JComboBox;

import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.DefaultComboBoxModel;

@SuppressWarnings("serial")
public class PatientInformationWindow extends JFrame implements IUserInfoView{

	private JPanel contentPane;
	private JTextField middleNameField;
	private JTextField firstNameField;
	private JTextField zipCodeField;
	private JTextField lastNameField;
	private JTextField emailField;
	private JTextField phone;
	private JTextField addressField;
	private JTextField cityField;
	private JRadioButton rdbtnMale;
	private JRadioButton rdbtnFemale;
	private JComboBox monthBox;
	private JComboBox dayBox;
	private JComboBox yearBox;
	private JComboBox stateComboBox;
	private JButton cancelButton;
	private JButton saveButton;
	private ButtonGroup group;


	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					PatientInformationWindow frame = new PatientInformationWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public PatientInformationWindow() {
		setTitle("Dr. Doom Management");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 457, 510);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JLabel lblUserInformation = new JLabel("User Information");
		lblUserInformation.setHorizontalAlignment(SwingConstants.CENTER);
		contentPane.add(lblUserInformation, BorderLayout.NORTH);
		
		JPanel infoPanel = new JPanel();
		contentPane.add(infoPanel, BorderLayout.CENTER);
		infoPanel.setLayout(null);
		
		JLabel lblFirstNam = new JLabel("First Name");
		lblFirstNam.setBounds(20, 9, 79, 14);
		infoPanel.add(lblFirstNam);
		
		firstNameField = new JTextField();
		firstNameField.setBounds(122, 6, 309, 20);
		infoPanel.add(firstNameField);
		
		JLabel lblMiddleName = new JLabel("Middle Name");
		lblMiddleName.setBounds(20, 35, 90, 14);
		infoPanel.add(lblMiddleName);
		
		middleNameField = new JTextField();
		middleNameField.setBounds(122, 32, 309, 20);
		infoPanel.add(middleNameField);
		middleNameField.setColumns(10);
		
		JLabel lblLastName = new JLabel("Last Name");
		lblLastName.setBounds(20, 61, 66, 14);
		infoPanel.add(lblLastName);
		
		lastNameField = new JTextField();
		lastNameField.setBounds(122, 58, 309, 20);
		infoPanel.add(lastNameField);
		lastNameField.setColumns(10);
		
		JLabel lblEmail = new JLabel("Email");
		lblEmail.setBounds(20, 87, 60, 14);
		infoPanel.add(lblEmail);
		
		emailField = new JTextField();
		emailField.setBounds(122, 84, 309, 20);
		infoPanel.add(emailField);
		emailField.setColumns(10);
		
		JLabel lblGender = new JLabel("Gender");
		lblGender.setBounds(20, 165, 60, 14);
		infoPanel.add(lblGender);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(122, 157, 309, 33);
		infoPanel.add(panel_1);
		
		rdbtnMale = new JRadioButton("Male");
		panel_1.add(rdbtnMale);
		
		rdbtnFemale = new JRadioButton("Female");
		panel_1.add(rdbtnFemale);
		
		JLabel lblBirthday = new JLabel("Birthday");
		lblBirthday.setBounds(20, 208, 60, 14);
		infoPanel.add(lblBirthday);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBounds(122, 201, 309, 33);
		infoPanel.add(panel_2);
		
		monthBox = new JComboBox();
		monthBox.setModel(new DefaultComboBoxModel(new String[] {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}));
		monthBox.setSelectedIndex(0);
		panel_2.add(monthBox);
		
		dayBox = new JComboBox();
		dayBox.setModel(new DefaultComboBoxModel(new String[] {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"}));
		dayBox.setSelectedIndex(0);
		panel_2.add(dayBox);
		
		yearBox = new JComboBox();
		yearBox.setModel(new DefaultComboBoxModel(new String[] {"2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956", "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", "1943", "1942", "1941", "1940", "1939", "1938", "1937", "1936", "1935", "1934", "1933", "1932", "1931", "1930", "1929", "1928", "1927", "1926", "1925", "1924", "1923", "1922", "1921", "1920", "1919", "1918", "1917", "1916", "1915", "1914", "1913", "1912", "1911", "1910", "1909", "1908", "1907", "1906", "1905", "1904", "1903", "1902", "1901", "1900"}));
		yearBox.setSelectedIndex(0);
		panel_2.add(yearBox);
		
		JLabel lblAddress = new JLabel("Phone");
		lblAddress.setBounds(20, 113, 60, 14);
		infoPanel.add(lblAddress);
		
		phone = new JTextField();
		phone.setBounds(122, 110, 309, 20);
		infoPanel.add(phone);
		phone.setColumns(10);
		
		JLabel lblAddres = new JLabel("Address");
		lblAddres.setBounds(20, 248, 60, 14);
		infoPanel.add(lblAddres);
		
		addressField = new JTextField();
		addressField.setBounds(122, 245, 309, 20);
		infoPanel.add(addressField);
		addressField.setColumns(10);
		
		JLabel lblCity = new JLabel("City");
		lblCity.setBounds(20, 279, 60, 14);
		infoPanel.add(lblCity);
		
		cityField = new JTextField();
		cityField.setBounds(122, 276, 309, 20);
		infoPanel.add(cityField);
		cityField.setColumns(10);
		
		JLabel lblState = new JLabel("State");
		lblState.setBounds(20, 308, 60, 14);
		infoPanel.add(lblState);
		
		stateComboBox = new JComboBox();
		stateComboBox.setBounds(122, 305, 309, 20);
		stateComboBox.setModel(new DefaultComboBoxModel(new String[] {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming", "District of Columbia", "Puerto Rico", "Guam", "American Samoa", "U.S. Virgin Islands", "Northern Mariana Islands"}));
		infoPanel.add(stateComboBox);
		
		JLabel lblZipCode = new JLabel("Zip Code");
		lblZipCode.setBounds(20, 339, 60, 14);
		infoPanel.add(lblZipCode);
		
		zipCodeField = new JTextField();
		zipCodeField.setBounds(122, 336, 309, 20);
		infoPanel.add(zipCodeField);
		zipCodeField.setColumns(10);
		zipCodeField.setColumns(10);
		
		JPanel actionButtons = new JPanel();
		contentPane.add(actionButtons, BorderLayout.SOUTH);
		actionButtons.setLayout(new BorderLayout(0, 0));
		
		cancelButton = new JButton("Cancel");
		actionButtons.add(cancelButton, BorderLayout.WEST);
		
		saveButton = new JButton("Save");
		actionButtons.add(saveButton, BorderLayout.EAST);
		
		
		group = new ButtonGroup();
		group.add(rdbtnMale);
		group.add(rdbtnFemale);
		
		
	}

	/**
	 * @return the firstNameField
	 */
	public JTextField getFirstNameField() {
		return firstNameField;
	}
	
	/**
	 * @return the middleNameField
	 */
	public JTextField getMiddleNameField() {
		return middleNameField;
	}



	/**
	 * @return the zipCodeField
	 */
	public JTextField getZipCodeField() {
		return zipCodeField;
	}

	/**
	 * @return the lastNameField
	 */
	public JTextField getLastNameField() {
		return lastNameField;
	}

	/**
	 * @return the emailField
	 */
	public JTextField getEmailField() {
		return emailField;
	}

	/**
	 * @return the homePhone
	 */
	public JTextField getPhone() {
		return phone;
	}


	/**
	 * @return the addressField
	 */
	public JTextField getAddressField() {
		return addressField;
	}

	/**
	 * @return the cityField
	 */
	public JTextField getCityField() {
		return cityField;
	}

	/**
	 * @return the rdbtnMale
	 */
	public JRadioButton getRdbtnMale() {
		return rdbtnMale;
	}

	/**
	 * @return the rdbtnFemale
	 */
	public JRadioButton getRdbtnFemale() {
		return rdbtnFemale;
	}

	/**
	 * @return the monthBox
	 */
	public JComboBox getMonthBox() {
		return monthBox;
	}

	/**
	 * @return the dayBox
	 */
	public JComboBox getDayBox() {
		return dayBox;
	}

	/**
	 * @return the yearBox
	 */
	public JComboBox getYearBox() {
		return yearBox;
	}

	/**
	 * @return the stateComboBox
	 */
	public JComboBox getStateComboBox() {
		return stateComboBox;
	}

	/**
	 * @return the cancelButton
	 */
	public JButton getCancelButton() {
		return cancelButton;
	}

	/**
	 * @return the saveButton
	 */
	public JButton getSaveButton() {
		return saveButton;
	}
	
	/**
	 * @return the group
	 */
	public ButtonGroup getGroup() {
		return group;
	}

	@Override
	public void showSelf() {
		this.setVisible(true);
		
	}

	@Override
	public void addListener(ActionListener al) {
		
		middleNameField.addActionListener(al);
		firstNameField.addActionListener(al);
		zipCodeField.addActionListener(al);
		lastNameField.addActionListener(al);
		emailField.addActionListener(al);
		phone.addActionListener(al);
		addressField.addActionListener(al);
		cityField.addActionListener(al);
		rdbtnMale.addActionListener(al);
		rdbtnFemale.addActionListener(al);
		monthBox.addActionListener(al);
		dayBox.addActionListener(al);
		yearBox.addActionListener(al);
		stateComboBox.addActionListener(al);
		cancelButton.addActionListener(al);
		saveButton.addActionListener(al);
		
	}

	@Override
	public void hideSelf() {
		this.setVisible(false);
	}
}
